Built with 🦀🕸 by The Rust and WebAssembly Working Group
Working with timers on the Web: setTimeout
and setInterval
.
These APIs come in two flavors:
- a callback style (that more directly mimics the JavaScript APIs), and
- a
Future
s andStream
s API.
Timeouts
Timeouts fire once after a period of time (measured in milliseconds).
Timeouts with a Callback Function
use Timeout;
let timeout = new;
// Since we don't plan on cancelling the timeout, call `forget`.
timeout.forget;
Timeouts as Future
s
With the futures
feature enabled, a future
module containing futures-based
timers is exposed.